////#define _CRT_SECURE_NO_WARNINGS
//////
//////#include<stdio.h>
//////#include<stdlib.h>
//////#include<string.h>
////////
////////char* my_strtok(char* str, const char* delimiters)
////////{
////////	static char* temp = NULL;
////////
////////	if (str != NULL)
////////	{
////////		char* head1 = str;
////////		while (*head1)
////////		{
////////			char* head2 = delimiters;
////////			while (*head2)
////////			{
////////				if (*head1 != *head2)
////////					head2++;
////////				else
////////				{
////////					*head1 = '\0';
////////					temp = head1 + 1;
////////					return str;
////////				}
////////			}
////////			head1++;
////////		}
////////		return str;
////////	}
////////	else
////////	{
////////		if (temp == NULL)
////////			return NULL;
////////		char* head1 = temp;
////////		char* cur = temp;
////////		while (*head1)
////////		{
////////			char* head2 = delimiters;
////////			while (*head2)
////////			{
////////				if (*head1 != *head2)
////////					head2++;
////////				else
////////				{
////////					*head1 = '\0';
////////					temp = head1 + 1;
////////					return cur;
////////				}
////////			}
////////			head1++;
////////		}
////////		temp = NULL;
////////		return cur;
////////	}
////////}
////////
////////void Text1()
////////{
////////	char str[] = "hhh333@qq.com";
////////	char seq[] = "@.";
////////	char _str[100] = { 0 };
////////
////////	strcpy(_str, str);
////////
////////	printf("%s\n", my_strtok(_str, seq));
////////	printf("%s\n", my_strtok(NULL, seq));
////////	printf("%s\n", my_strtok(NULL, seq));
////////}
////////
////////void Text2()
////////{
////////	char str[] = "hhh333@qq.com";
////////	char seq[] = "@.";
////////	char _str[100] = { 0 };
////////
////////	strcpy(_str, str);
////////
////////	char* temp = my_strtok(_str, seq);
////////
////////	for (; temp != NULL; temp = my_strtok(NULL, seq))
////////	{
////////		printf("%s\n", temp);
////////	}
////////
////////}
////////
//////int main()
//////{
//////	char str[] = "abcd";
//////	strncat(str, str,1);
//////	printf("%s\n", str);
//////
//////	return 0;
////////
////////}
////////
////////#include<stdio.h>
////////
////////char* my_strcat(char* destination, const char* source)
////////{
////////	char* head = destination;
////////
////////	while (*destination)
////////		destination++;
////////
////////	while (*source)
////////	{
////////		*destination++ = *source++;
////////	}
////////	*destination = '\0';
////////
////////	return head;
////////}
////////
////////int main()
////////{
////////	char str1[20] = "abcde";
////////	char str2[20] = "abcde";
////////
////////	printf("%s\n", my_strcat(str1, str1));
////////
////////	return 0;
////////}
////
////#include<stdio.h>
////#include<string.h>
////#include<errno.h>
////
//////int main()
//////{
//////	FILE* fp = fopen("unexist.txt", "r");
//////	if (fp == NULL)
//////	{
//////		printf("Error opening unexist.txt: %s\n", strerror(errno));
//////	}
//////
//////	return 0;
//////}
////
//////int main()
//////{
//////	for (int i = 1; i < 9; i++)
//////		printf("%s\n", strerror(i));
//////
//////	return 0;
//////}
////void* my_memcpy(void* destination, const void* source, size_t num)
////{
////	void* head = destination;
////
////	while (num--)
////	{
////		*(char*)destination = *(char*)source;
////
////		((char*)destination)++;
////		((char*)source)++;
////	}
////
////	return head;
////}
////
//////int main()
//////{
//////	int num1[20] = { 0 };
//////	int num2[] = { 1,2,3,4,5 };
//////
//////	my_memcpy(num1, num2, sizeof(num2));
//////
//////	for (int i = 0; i < sizeof(num1) / sizeof(int); i++)
//////		printf("%d ", num1[i]);
//////	printf("\n");
//////
//////	return 0;
//////}
////
////void* my_memmove(void* destination, const void* source, size_t num)
////{
////	void* head = destination;
////
////	if (destination < source)
////	{
////		while (num--)
////		{
////			*(char*)destination = *(char*)source;
////
////			((char*)destination)++;
////			((char*)source)++;
////		}
////	}
////	else
////	{
////		while (num--)
////		{
////			*((char*)destination + num) = *((char*)source + num);
////		}
////	}
////
////	return head;
////}
////
//////int main()
//////{
//////	int num[] = { 1,2,3,4,5,6,7,8,9,10 };
//////	my_memmove(num, num + 2, 5 * sizeof(int));
//////
//////	for (int i = 0; i < sizeof(num) / sizeof(int); i++)
//////		printf("%d ", num[i]);
//////	printf("\n");
//////	
//////	return 0;
//////}
////
////int my_memcmp(const void* ptr1, const void* ptr2, size_t num)
////{
////	while (num-- && *(char*)ptr1 == *(char*)ptr2)
////	{
////		((char*)ptr1)++;
////		((char*)ptr2)++;
////	}
////
////	if (num + 1 == 0)
////		return 0;
////	else if (*(char*)ptr1 > *(char*)ptr2)
////		return 1;
////	else
////		return -1;
////}
////
//////int main()
//////{
//////	int num1[] = { 1,2,3,4,5,8 };
//////	int num2[] = { 1,2,3,4,5,7 };
//////
//////	if (my_memcmp(num1, num2, 6 * sizeof(int)) > 0)
//////		printf(">\n");
//////	else if (my_memcmp(num1, num2, 6 * sizeof(int)) < 0)
//////		printf("<\n");
//////	else
//////		printf("=\n");
//////
//////	return 0;
//////}
////
////void* my_memset(void* ptr, int value, size_t num)
////{
////	void* head = ptr;
////
////	while (num--)
////	{
////		*(char*)ptr = value;
////		((char*)ptr)++;
////	}
////
////	return head;
////}
////
////int main()
////{
////	int nums[5] = { 1,1,1,1,1 };
////
////	my_memset(nums, 0, sizeof(nums));
////
////	for (int i = 0; i < sizeof(nums) / sizeof(int); i++)
////		printf("%d ", nums[i]);
////	printf("\n");
////
////	my_memset(nums, 1, sizeof(nums));
////
////	for (int i = 0; i < sizeof(nums) / sizeof(int); i++)
////		printf("%d ", nums[i]);
////	printf("\n");
////
////	return 0;
////}
//
//#include<stdio.h>
//
//void* my_memcpy(void* destination, const void* source, size_t num)
//{
//	while (num--)
//	{
//		*(char*)destination = *(char*)source;
//
//		((char*)destination)++;
//		((char*)source)++;
//	}
//}
//
//int main()
//{
//	int num1[20] = { 0 };
//	int num2[] = { 1,2,3,4,5 };
//
//	my_memcpy(num1, num2, sizeof(num2));
//
//	for (int i = 0; i < sizeof(num1) / sizeof(int); i++)
//		printf("%d ", num1[i]);
//	printf("\n");
//
//	return 0;
//}

#include<stdio.h>

void* my_memmove(void* destination, const void* source, size_t num)
{
	void* head = destination;

	if (destination < source)
	{
		while (num--)
		{
			*(char*)destination = *(char*)source;

			((char*)destination)++;
			((char*)source)++;
		}
	}
	else
	{
		while (num--)
		{
			*((char*)destination + num) = *((char*)source + num);
		}
	}

	return head;
}

int main()
{
	int num[] = { 1,2,3,4,5,6,7,8,9,10 };
	my_memmove(num, num + 2, 5 * sizeof(int));

	for (int i = 0; i < sizeof(num) / sizeof(int); i++)
		printf("%d ", num[i]);
	printf("\n");

	return 0;
}